﻿using System.Collections.Generic;
using RBOSS.Business.Products;
using RBOSS.Business.ShoppingCarts;
using RBOSS.Business.Views;

namespace RBOSS.Business.Presenters
{
    public class ProductPresenter
    {
        private IProductView _view;
        private readonly IShoppingCartSubsystem _shoppingCart;
        private readonly IProductSubsystem _productSubsystem;
        public ProductPresenter(IProductView view)
        {
            _view = view;
            _shoppingCart = new ShoppingCartSubsystem();
            _productSubsystem = new ProductSubsystem();
        }

        public void AddItemToCart(int productId,int quantity)
        {
            _shoppingCart.AddItemToCart(GetProduct(productId),quantity);
        }

        public IProduct GetProduct(int productId)
        {
            return _productSubsystem.GetProduct(productId);
        }

        public List<ProductItem> GetProducts()
        {
            return _productSubsystem.GetProducts();
        }

        public List<ProductItem> GetProductByCategory(string category)
        {
            return _productSubsystem.GetProductsByCategory(category);
        }

        public List<ProductItem> SearchProduct(string productName)
        {
            return _productSubsystem.SearchProduct(productName);
        }
    }
}